package com.pi.shisan.service.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.pi.shisan.service.domain.ClockInfo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface ClockInfoMapper extends BaseMapper<ClockInfo> {


    @Update("update led_clock_info set clk_hour = null where id = #{id}")
    int clearHourInfo(@Param("id") Long id);

    @Update("update led_clock_info set clk_week = null where id = #{id}")
    int clearWeekInfo(@Param("id") Long id);

    @Update("update led_clock_info set clk_day = null where id = #{id}")
    int clearDayInfo(@Param("id")Long id);

    @Update("update led_clock_info set clk_month = null where id = #{id}")
    int clearMonthInfo(@Param("id") Long id);

    @Update("update led_clock_info set clk_year = null where id = #{id}")
    int clearYearInfo(@Param("id") Long id);

    @Update("update led_clock_info set clk_status = 1 where id = #{id}")
    int setToAvailableClock(@Param("id") Long id);

    @Update("update led_clock_info set clk_status = 0 where id = #{id}")
    int setToUnavailableClock(@Param("id") Long id);

    @Update("update led_clock_info set clk_switch = #{switchState} where id = #{id}")
    int onOffClock(@Param("id") Long id, @Param("switchState") Integer switchState);

    @Select("select * from led_clock_info where id > #{id} and clk_status = 1 and clk_switch = 1 order by id asc limit #{limit}")
    List<ClockInfo> selectForPage(@Param("id") Long startId, @Param("limit") Integer limit);

    @Update("update led_clock_info set clk_volume = #{volume} where id = #{id}")
    int updateVolume(@Param("id") Long id, @Param("volume") Integer volume);
}
